package com.example.demo.controller;
import com.example.demo.entity.CommonResult;
import com.example.demo.service.SaleMangeService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
public class SaleMangeController {

    @Autowired
    SaleMangeService  saleMangeService;

    @ResponseBody
    @GetMapping("/sell/get_salegoods_Onepage")
    @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "第几页，不传递默认第一页", dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "一页的数据量，默认10条数据 ",  dataType = "Integer", paramType = "query")})
    @ApiOperation(notes = "销售管理", value = "get_salegoods_Onepage")
    public CommonResult getOnepage(@RequestParam(value ="pageNum", defaultValue = "1")Integer pageNum,
                                   @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
        CommonResult commonResult = saleMangeService.GetOnepagesale(pageNum, pageSize);
        return commonResult;
    }

    @ResponseBody
    @GetMapping("/sell/selectsalegoods")
    @ApiOperation(notes = "根据时间和名字查询", value = "selectsalegoods")
    public CommonResult selectUser(String drug_id, String sale_time) {
        if (drug_id==null && sale_time==null){
            return new CommonResult(401,"不能空参查询");
        }
        CommonResult selectsalegoods = saleMangeService.selectsalegoods(drug_id, sale_time);
        return selectsalegoods;
    }

}
